from tool import enumtools

def format_result(data, succeed_message=enumtools.enum_succeed, fail_message=enumtools.enum_fail):
    if data:
        response = {
            "code": enumtools.enum_succeed_num,
            "err": enumtools.enum_num_zero,
            "message": succeed_message,
            "data": {"userinfo": data}
        }
    else:
        response = {
            "code": enumtools.enum_fail_num,
            "err": enumtools.enum_num_one,
            "message": fail_message,
            "data": {}
        }
    return response